class CompanyController < ApplicationController

  helper :all # include all helpers, all the time. TODO: revise this??
  
  def index

    @pageTitle = "Electric Power Industry Companies"
        
    conditions = {}
    conditions[:ownertype] = params[:owner] if params[:owner]
    
    if params[:state]
      conditions[:state] = params[:state]
    else
      conditions[:state] = DEFAULT_STATE_ABBR
      params[:state] = DEFAULT_STATE_ABBR
    end
    
    @companies = Company.paginate :page => params[:page], :conditions => conditions

    if conditions[:ownertype]
      @searchMsg = Company::OWNER_TYPES[conditions[:ownertype]]
    else
      @searchMsg = "All"
    end
    
    @searchMsg += " companies in " + STATE_ABBR[conditions[:state]].to_s

  end

  def view
     @company = Company.find(params[:id])
     @pageTitle = @company.name
  end

end
